<!--
 * @Author: lvye
 * @Description:
 * @Date: 2023-07-06 16:19:03
 * @LastEditTime: 2023-07-28 15:15:23
 * @FilePath: \vue3-ts\vue3-ts\src\views\login\cpns\login-panel.vue
-->
<template>
  <div class="login-panel">
    <h1>后台管理系统</h1>
    <el-tabs type="border-card" stretch class="panel-tabs" v-model="currentTab">
      <el-tab-pane>
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><calendar /></el-icon>
            <span>账号登录</span>
          </span>
        </template>
        <loginAccount ref="accountRef"></loginAccount>
      </el-tab-pane>
      <el-tab-pane>
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><Iphone /></el-icon>
            <span>手机登录</span>
          </span>
        </template>
        <loginPhone></loginPhone>
      </el-tab-pane>
    </el-tabs>
    <div class="account-control">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>

    <el-button type="primary" class="login-btn" @click="handleLoginClick"
      >立即登录</el-button
    >
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue"
import loginAccount from "./login-account.vue"
import loginPhone from "./login-phone.vue"
export default defineComponent({
  components: {
    loginAccount,
    loginPhone
  },
  setup() {
    const isKeepPassword = ref(false)
    const currentTab = ref("0")
    const accountRef = ref<InstanceType<typeof loginAccount>>()
    const handleLoginClick = () => {
      console.log(currentTab.value)
      if (currentTab.value === "0") {
        accountRef.value?.loginAction(isKeepPassword.value)
      }
    }
    return {
      isKeepPassword,
      currentTab,
      accountRef,
      handleLoginClick
    }
  }
})
</script>

<style lang="less">
.login-panel {
  text-align: center;
  width: 320px;

  .account-control {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
  }

  .login-btn {
    width: 100%;
    margin-top: 10px;
  }
}
</style>
